package com.fuzamei.rent.service;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

@Service
public class HelloworldService {

    @Autowired
    RestTemplate restTemplate;
    Logger logger = Logger.getLogger(HelloworldService.class);

    @HystrixCommand(fallbackMethod = "helloFallback")
    public String helloService(){
        String result = restTemplate.getForEntity("http://HELLO-SERVICE/hello",String.class).getBody();
        logger.info("hello接口的返回数据："+result);
        return result;
    }


    public String helloFallback(){
        return "helloworld服务当前不可用";
    }
}
